<?php
/**
 * Created by PhpStorm.
 * User: Shen
 * Date: 2016/6/23
 * Time: 21:05
 */
include_once 'database.php';

function getCatePath($cid,&$result=array()){
    $sql = "SELECT * FROM cate WHERE id = $cid";
    $rs = mysql_query($sql);
    $row = mysql_fetch_assoc($rs);
    if ($row){
        $result[] = $row;
        getCatePath($row['pid'],$result);
    }
    krsort($result);
    return $result;
}



//echo '<pre>';
//
//print_r($res);
//
//echo '</pre>';

function dispaly($cid,$url="cate.php?cid="){
    $res = getCatePath($cid);
    $str = '';
    foreach ($res as $key => $val) {
        $str .= "<a href='{$url}{$val['id']}'>{$val['catename']}</a>>";
    }
    return $str;
}

echo dispaly(10,'deeplink.php?cid=1');


